package basic50.fiftieth;

import java.util.Scanner;

public class Basic48 {
    public static void main(String[] args) {
     //   题目：某个公司采用公用电话传递数据，数据是四位的整数，在传递过程中是加密的，
        //   加密规则如下：每位数字都加上5,然后用和除以10的余数代替该数字，再将第一位和第四位交换，第二位和第三位交换。
        Scanner in = new Scanner(System.in);
        int number = in.nextInt();
        while (number>=1000 && number<=9999) {
            int ge = number % 10;
            number /= 10;
            int shi = number % 10;
            number /= 10;
            int bai = number % 10;
            number /= 10;
            int qian = number % 10;
            number /= 10;
            int cryptoGe = getCryptoGe(ge);
            int cryptoShi = getCryptoGe(shi);
            int cryptoBai = getCryptoGe(bai);
            int cryptoQian = getCryptoGe(qian);
            int temp = cryptoGe;
            cryptoGe = cryptoQian;
            cryptoQian = temp;
            temp = cryptoBai;
            cryptoBai = cryptoShi;
            cryptoShi = temp;
            int result = cryptoGe+ cryptoShi*10 + cryptoBai*100 + cryptoQian*1000;
            System.out.println(result);
        }
    }

    private static int getCryptoGe(int ge) {
        return (ge + 5) % 10;
    }
}
